﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using cmdb.keede.common;
using cmdb.keede.entity;
using cmdb.keede.service;
using cmdb.keede.service.Contract;
using Microsoft.AspNetCore.Mvc;

namespace cmdb.keede.com.Controllers
{
    public class VirtualHostController : Controller
    {
        private readonly IVirtualHostInfoService _virtualHostInfoService;

        public VirtualHostController(IVirtualHostInfoService virtualHostInfoService)
        {
            _virtualHostInfoService = virtualHostInfoService;
        }

        public IActionResult Index()
        {
            return View();
        }

        public async Task<BizResult<List<VirtualHostInfo>>> GetVirtualHostInfoes(VirtualHostInfoRequest request, int pageIndex, int pageSize)
        {

            return await _virtualHostInfoService.GetVirtualHostInfoesAsync(request, pageIndex, pageSize);
        }

        public async Task<BizResult<VirtualHostInfo>> GetVirtualHostInfo(int id)
        {
            return await _virtualHostInfoService.GetVirtualHostInfoAsync(id);
        }

        public async Task<BizResult<bool>> DeleteVirtualHostInfo(int id)
        {
            return await _virtualHostInfoService.DeleteVirtualHostInfoAsync(id);
        }

        [HttpPost]
        public async Task<BizResult<bool>> AddOrUpdateVirtualHostInfo(VirtualHostInfo virtualHostInfo)
        {
            return await _virtualHostInfoService.AddOrUpdateAppInfoAsync(virtualHostInfo);
        }
    }
}